package country_setting

import (
	cb "hft/Database/admin/country_setting"
	"hft/Http/Models/request"
	"hft/Http/Services/country_setting"
	"hft/Http/Services/country_setting/setting_model"
	utils "hft/Http/Utils"
	"hft/e"

	"github.com/gin-gonic/gin"
)

type Emoji struct{}

func (*Emoji) List(c *gin.Context) {
	var paginate setting_model.EmojiSearch
	if err := c.ShouldBind(&paginate); err == nil {
		if list, err := country_setting.EmojiService.List(&paginate); err != nil {
			utils.FailWithMessage(err.Error(), c)
		} else {
			utils.OkWithData(list, c)
		}
	} else {
		utils.FailWithMessage(e.ErrorInfo, c)
	}
}

func (*Emoji) Add(c *gin.Context) {
	var data *cb.Emoji
	if err := c.ShouldBindJSON(&data); err == nil {
		if err = country_setting.EmojiService.Add(data); err != nil {
			utils.FailWithMessage(err.Error(), c)
		} else {
			utils.Ok(c)
		}
	} else {
		utils.FailWithMessage(e.ErrorInfo, c)
	}
}

func (*Emoji) Edit(c *gin.Context) {
	var data *cb.Emoji
	if err := c.ShouldBindJSON(&data); err == nil {
		if err = country_setting.EmojiService.Edit(data); err != nil {
			utils.FailWithMessage(err.Error(), c)
		} else {
			utils.Ok(c)
		}
	} else {
		utils.FailWithMessage(e.ErrorInfo, c)
	}
}

func (*Emoji) Delete(c *gin.Context) {
	var IDS *request.IDS
	if err := c.ShouldBindJSON(&IDS); err == nil {
		if err = country_setting.EmojiService.Delete(IDS.IDS); err != nil {
			utils.FailWithMessage(err.Error(), c)
		} else {
			utils.Ok(c)
		}
	} else {
		utils.FailWithMessage(e.ErrorInfo, c)
	}
}

var EmojiController = new(Emoji)
